package org.example.oss.contorller;

import org.example.core.utils.R;
import org.example.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 小杰_cc
 * @version 1.0
 */
@RestController
@RequestMapping("/oss/backend")
public class OssController {

    @Autowired
    private OssService ossService;

    // 获取上传凭证
    @GetMapping("/policy")
    public R<Map<String,String>> getPolicy(){
        Map<String,String> resMap = ossService.getPolicy();
        return R.ok(resMap);
    }

    // 删除单个文件
    @DeleteMapping("/delete")
    public R<?> remove(@RequestParam String name){
        ossService.remove(name);
        return R.ok();
    }

    // 删除多个文件
    @DeleteMapping("/deletes")
    public R<?> removes(@RequestBody List<String> names){
        ossService.removes(names);
        return R.ok();
    }
}
